js
import {watchEffect, ref } from "vue"
const msg = ref("后撤步!")
watchEffect(()=>{
console.log(msg.value)
})
setTimeout(()=>{
msg.value = "7777"
},1000)
ts
export function watchEffect(
effect: WatchEffect,
options?: WatchOptionsBase
): WatchStopHandle {
const opts = getWatchEffectOption(options)
const vm = getWatcherVM()
return createWatcher(vm, effect, null, opts)
}